import { useSuspenseQuery } from "@tanstack/react-query";
import { createFileRoute } from "@tanstack/react-router";
import { OrganizationDataTable } from "@/components/organization/table";
import { orgsQueryOptions } from "@/queries/auth";

export const Route = createFileRoute("/_app/organizations")({
  component: RouteComponent,
});

function RouteComponent() {
  const context = Route.useRouteContext();
  const { data: orgs } = useSuspenseQuery(orgsQueryOptions(context.session.user.id));
  return <OrganizationDataTable data={orgs} />;
}
